﻿using System;

namespace NazTek.Utility.Extensions.Misc
{
    /// <summary>
    /// Extends generic type.
    /// </summary>
    public static class TypeExtension
    {
        /// <summary>
        /// Extracts custom attributes from a type.
        /// </summary>
        /// <typeparam name="T">The type of the custom attribute.</typeparam>
        /// <param name="type">The type to extract custom attributes from.</param>
        /// <returns>Hydrated custom attribute instance.</returns>
        public static T GetCustomAtribute<T>(this Type type) where T : class
        {
            return (Attribute.GetCustomAttribute(type, typeof (T)) as T);
        }
    }
}